{extend name="public/base" /}
{block name="sidebar"}
{include file="appointment/sidemenu" /}
{/block}
{block name="body"}
<!-- 标题栏 -->
<div class="main-title">
    <h2>预约列表[ {if condition="get_order_status($status) eq ''"}所有{else/}{:get_order_status($status)}{/if} ]</h2>
</div>
<div class="cf">
    <div class="fl">
        <button class="btn ajax-post confirm" url="{:url('changeStatus?method=processappoint')}" target-form="ids">处理订单</button>
        <button class="btn ajax-post confirm" url="{:url('changeStatus?method=signAppoint')}" target-form="ids">标记问题</button>
        <button class="btn ajax-post confirm" url="{:url('changeStatus?method=deleteAppoint')}" target-form="ids">删 除</button>
        <a class="btn" href="{:url('Appointment/recycle')}">回收站</a>
    </div>

    <!-- 高级搜索 -->
    <div class="search-form fr cf">
        <div class="sleft">
            <div class="drop-down">
                <span id="sch-sort-txt" class="sort-txt" data="{$status}">{if condition="get_order_status($status) eq ''"}所有{else/}{:get_order_status($status)}{/if}</span>
                <i class="arrow arrow-down"></i>
                <ul id="sub-sch-menu" class="nav-list hidden">
                    <li><a href="javascript:;" value="">所有</a></li>
                    <li><a href="javascript:;" value="1">未处理</a></li>
                    <li><a href="javascript:;" value="2">已处理</a></li>
                    <li><a href="javascript:;" value="0">问题订单</a></li>
                </ul>
            </div>
            <input type="text" name="mobile" class="search-input" value="{:input('mobile')}" placeholder="请输入手机号">
            <a class="sch-btn" href="javascript:;" id="search" url="{:url('appointment/index')}"><i class="btn-search"></i></a>
        </div>
        <div class="btn-group-click adv-sch-pannel fl">
            <button class="btn">高 级<i class="btn-arrowdown"></i></button>
            <div class="dropdown cf">
                <div class="row">
                    <label>预约时间：</label>
                    <input type="text" id="time-start" name="time-start" class="text input-2x" value="" placeholder="起始时间" /> -
                    <input type="text" id="time-end" name="time-end" class="text input-2x" value="" placeholder="结束时间" />
                </div>
                <div class="row">
                    <label>教 师：</label>
                    <input type="text" name="teacher" class="text input-2x" value="" placeholder="请输入教师名">
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 数据列表 -->
<div class="data-table table-striped">
    <table class="">
        <thead>
        <tr>
            <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
            <th class="">UID</th>
            <th class="">用户名</th>
            <th class="">邮箱</th>
            <th class="">手机号</th>
            <th class="">教师姓名</th>
            <th class="">预约时间</th>
            <th class="">状态</th>
            <th class="">操作</th>
        </tr>
        </thead>
        <tbody>
        {notempty name="_list"}
        {volist name="_list" id="vo"}
        <tr>
            <td><input class="ids" type="checkbox" name="id[]" value="{$vo.uid}" /></td>
            <td>{$vo.uid} </td>
            <td>{$vo.username}</td>
            <td>{$vo.email}</td>
            <td>{$vo.mobile}</td>
            <td>{$vo.name}</td>
            <td>{$vo.appoint_time}</td>
            <td>{$vo.status|get_order_status}</td>
            <td>{eq name="vo.status" value="1"}
                <a href="{:url('Appointment/changeStatus?method=processAppoint&id='.$vo['uid'])}" class="ajax-get">处理订单</a>
                <a href="{:url('Appointment/changeStatus?method=signAppoint&id='.$vo['uid'])}" class="ajax-get">标记问题</a>
                {else/}
                {eq name="vo.status" value="2"}
                <a href="{:url('Appointment/changeStatus?method=signAppoint&id='.$vo['uid'])}" class="ajax-get">标记问题</a>
                {/eq}
                {/eq}
                <a href="{:url('Appointment/changeStatus?method=deleteAppoint&id='.$vo['uid'])}" class="confirm ajax-get">删除</a>
            </td>
        </tr>
        {/volist}
        {else/}
        <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
        {/notempty}
        </tbody>
    </table>
</div>
<div class="page">
    {$_page}
</div>
{/block}

{block name="script"}
<script src="__PUBLIC__/static/thinkbox/jquery.thinkbox.js"></script>
<link href="__PUBLIC__/static/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
{php}if(config("color_style")=='blue_color') echo '<link href="__PUBLIC__/static/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';{/php}
<link href="__PUBLIC__/static/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__PUBLIC__/static/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/static/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
    //搜索功能
    $("#search").click(function(){
        var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
        window.location.href = url;
    });
    //回车搜索
    $(".search-input").keyup(function(e){
        if(e.keyCode === 13){
            $("#search").click();
            return false;
        }
    });
</script>

<script>
    $(function(){
        //搜索功能
        $("#search").click(function(){
            var url = $(this).attr('url');
            var status = $("#sch-sort-txt").attr("data");
            var query  = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
            query = query.replace(/^&/g,'');
            if(status != ''){
                query = 'status=' + status + "&" + query;
            }
            if( url.indexOf('?')>0 ){
                url += '&' + query;
            }else{
                url += '?' + query;
            }
            window.location.href = url;
        });

        /* 状态搜索子菜单 */
        $(".search-form").find(".drop-down").hover(function(){
            $("#sub-sch-menu").removeClass("hidden");
        },function(){
            $("#sub-sch-menu").addClass("hidden");
        });
        $("#sub-sch-menu li").find("a").each(function(){
            $(this).click(function(){
                var text = $(this).text();
                $("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
                $("#sub-sch-menu").addClass("hidden");
            })
        });


        //回车自动提交
        $('.search-form').find('input').keyup(function(event){
            if(event.keyCode===13){
                $("#search").click();
            }
        });

        $('#time-start').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
            minView:2,
            autoclose:true
        });

        $('#time-end').datetimepicker({
            format: 'yyyy-mm-dd',
            language:"zh-CN",
            minView:2,
            autoclose:true
        });
    })
</script>
{/block}
